home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
-
- #include <clib/exec_protos.h>
- #include <clib/dos_protos.h>
- #include <clib/graphics_protos.h>
- #include <clib/feelin_protos.h>
-
- #include <libraries/feelin.h>
-
- struct FeelinBase *FeelinBase;
-
- /// myAskMinMax
- __saveds ULONG myAskMinMax(struct FeelinClass *psClass,APTR Obj)
- {
- /*
- FM_AskMinMax will be called before the window is opened and before
- layout takes place. We need to tell Feelin the minimum and maximum size
- of our object.
- */
- _minw(Obj) += 100 ; _maxw(Obj) = 500;
- _minh(Obj) += 40 ; _maxh(Obj) = 300;
-
- return F_SuperDo(psClass,Obj,FM_AskMinMax);
- }
- //+
- /// MyDraw
- __saveds ULONG myDraw(struct FeelinClass *psClass,APTR Obj,struct FS_Draw *d)
- {
- ULONG i,c;
- struct RastPort *rp;
- UWORD x1,y1,x2,y2;
-
- /*
- let our superclass draw itself first, Area class would e.g. draw the
- frame and clear the whole region. What it does exactly depends on
- flags.
- */
-
- F_SuperDoA(psClass,Obj,FM_Draw,(ULONG *) d);
-
- // Ok, everything ready to render...
-
- rp = _rp(Obj);
- c = FV_Pen_Shine;
-
- x1 = _mx(Obj); x2 = _mx2(Obj);
- y1 = _my(Obj); y2 = _my2(Obj);
-
- for (i=x1 ; i<=x2 ; i+=5)
- {
- _APen(_pen(Obj,c));
- _Move(x1,y2); _Draw( i,y1);
- _Move(x2,y2); _Draw( i,y1);
- c++; if (c == FV_Pen_Highlight) {c = FV_Pen_Shine;}
- }
-
- return NULL;
- }
- //+
- /// myDispatcher
- /*
- Here is the beginning of our simple new class...
-
- This is an example for the simplest possible Feelin class. It's just
- some kind of custom image and supports only two methods: FM_AskMinMax
- and FM_Draw.
-
- This class is realy simple and do not requires any instance data.
- */
-
- ULONG ASM SAVEDS myDispatcher(REG_A2 struct FeelinClass *psClass,REG_A0 APTR Obj,REG_D0 ULONG nMethod,REG_A1 ULONG *pnArgs)
- {
-
- /*
- Here comes the dispatcher for our custom class. We only need to care
- about FM_AskMinMax and FM_Draw in this simple case. Unknown/unused
- methods are passed to the superclass immediately.
- */
- switch (nMethod)
- {
- case FM_AskMinMax : return myAskMinMax(psClass,Obj);
- case FM_Draw : return myDraw(psClass,Obj,(struct FS_Draw *)pnArgs);
- default : return F_SuperDoA(psClass,Obj,nMethod,pnArgs);
- }
- }
- //+
-
- /// Main
- void main()
- {
- APTR c,w;
- struct FeelinClass *fcc;
- UBYTE inner[] = {4,2,4,2};
-
- if (FeelinBase = (struct FeelinBase *)OpenLibrary("feelin.library",FV_VERSION))
- {
- if (fcc = F_CreateClass(FA_SuperID, FC_Area,
- FA_Dispatcher, myDispatcher,
- TAG_DONE))
- {
-
- c = ClientObject,
- FA_Client_Title, "Class1",
- FA_Client_Version, "$VER: Class1 1.00 (03-08-02)",
- FA_Client_Copyright, "©2002, Olivier Laviale",
- FA_Client_Author, "Olivier Laviale (lotan9@aol.com)",
- FA_Client_Description, "Demonstrate the use of custom classes.",
- FA_Client_Base, "CLASS1",
-
- Child, w = WindowObject,
- FA_ID, MAKE_ID('M','A','I','N'),
- FA_Window_Title, "A Simple Custom Class",
-
- Child, F_NewObj(fcc->ID,TextFrame, TextBack, FA_Inner,inner, TAG_DONE),
- End,
- End;
-
- if (c) {
- F_Do(w,FM_Notify,FA_Window_CloseRequest,TRUE,FV_Notify_Client,2,FM_Client_ReturnID,FV_Client_Quit);
- F_Set(w,FA_Window_Open,TRUE);
-
- F_DoA(c,FM_Client_Run,NULL);
-
- F_DisposeObj(c);
- }
-
- F_RemoveClass(fcc);
- } else {
- Printf("Unable to create custom class\n");
- }
-
- CloseLibrary((struct Library *)FeelinBase);
- } else {
- Printf("Unable to open feelin.library\n");
- }
- }
- //+
-